local skill = fk.CreateSkill {
  name = "ty__enemy_at_the_gates_skill",
}

Fk:loadTranslationTable{
  ["ty__enemy_at_the_gates_throw"] = "弃置装备区所有牌",
  ["ty__enemy_at_the_gates_damage"] = "受到1点伤害",
}

skill:addEffect("cardskill", {
  prompt = "#ty__enemy_at_the_gates_skill",
  mod_target_filter = function(self, player, to_select, selected, card, distance_limited)
    return to_select ~= player
  end,
  target_filter = Util.CardTargetFilter,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = effect.to
    local judge = {
      who = to,
      reason = "ty__enemy_at_the_gates",
      pattern = ".|.|spade,heart,club",
    }
    room:judge(judge)
    if judge:matchPattern() then
      local choices = {"ty__enemy_at_the_gates_damage"}
      if #to:getCardIds("e") > 0 then
      table.insert(choices, "ty__enemy_at_the_gates_throw")
    end
      if room:askToChoice(to, {
      choices = choices,
      skill_name = skill.name,
      }) == "ty__enemy_at_the_gates_damage" then
      room:damage{
      from = nil,
      to = to,
      damage = 1,
      skillName = skill.name,
    }
    else
      room:throwCard(to:getCardIds("e"), skill.name, to, to)
    end
    end
    self:onNullified(room, effect)
  end,
  on_nullified = function(self, room, effect)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse,
    }
  end,
})

skill:addAI(nil, "__card_skill")

return skill